
#include <Inklude/ikCarchiver.h>
#include <Inklude/ikCTimer.h>
#include <Inklude/ikCString.h>
#include <time.h>
#include <tchar.h>
#include <fstream>


using namespace Inklude;

static const int maxSize = 800*600;

void fillBuffer(float* ptr)
{
    srand(time(NULL));
    for (int i=0; i<maxSize; i++)
    {
        ptr[i] = (float)(rand() % 1000) / (float)(rand() % 1000);
    }
}

int _tmain(int argc, _TCHAR* argv[])
{   
    static const unsigned int orgSize = maxSize * sizeof(float);
    float* source = new float[maxSize];

    
    char* bufferSrc = new char[orgSize];
    char* bufferDest = new char[orgSize];
    char* bufferDecompressed = new char[orgSize];

    
    unsigned int compressedSize = orgSize;
    unsigned int decompressedSize = orgSize;

    ikCTimer timer;

    for (int i=0; i<100; i++)
    {
        /*ikCString fileName, tmp;
        fileName = "D:\\pic\\test_set\\800_600\\Image";
        tmp = i;
        fileName = fileName + tmp;
        fileName = fileName + ".bmp";
        std::ifstream inFile;
        inFile.open(fileName.c_str(), std::ios_base::binary);
        inFile.read(bufferSrc, orgSize);
        inFile.close();*/

        fillBuffer(source);

        timer.Start();
        ikCarchiver::CompressZlib(source, orgSize, bufferDest, compressedSize);
        printf("%f, %f\n", timer.ElapsedMilliseconds(), (float)compressedSize / (float)orgSize);
        timer.Stop();

        compressedSize = orgSize;
        timer.Start();
        ikCarchiver::CompressQpress(source, orgSize, bufferDest, compressedSize);
        printf("%f, %f\n", timer.ElapsedMilliseconds(), (float)compressedSize / (float)orgSize);
        timer.Stop();
    }

    //inFile.open("D:\\DSC_1108.bmp", std::ios_base::binary);
    //inFile.read(bufferSrc, orgSize);
    //inFile.close();

    //unsigned int compressedSize = orgSize;
    //unsigned int decompressedSize = orgSize;
    //Inklude::ikCarchiver arch;


    //arch.Compress(bufferSrc, orgSize, bufferDest, compressedSize);
    //arch.Decompress(bufferDest, compressedSize, bufferDecompressed, decompressedSize);

    //std::ofstream outFile;
    //outFile.open("D:\\abcddef.bmp", std::ios_base::binary);
    //outFile.write(bufferDecompressed, decompressedSize);
    //outFile.close();
	return 0;
}

